
/*
 * Brief:   Bitmap Interface
 *
 * File:    core/tp_bitmap.h
 * Author:  huangsanyi <huangsanyi@gmail.com>
 *
 */

/*
 * History:
 * 1,2013-1-20,huangsanyi,created.
 */

#ifndef TP_BITMAP_H
#define TP_BITMAP_H

TP_DECL_BEGIN

struct _TpBitmap;
typedef struct _TpBitmap TpBitmap;

/** Create a new bitmap with the given size and color.
 *
 * @param w The bitmap's width.
 * @param h The bitmap's height.
 * @param color The bitmap's background color. NULL indicated that it's transparent.
 *
 * @ret The created bitmap
 */
TpBitmap* tp_bitmap_create(int w, int h, const TpColor* color);

/** Destroy the given bitmap.
 *
 * @param bitmap
 */
void tp_bitmap_destroy(TpBitmap* bitmap);

/** Get the width of the given bitmap.
 *
 * @param bitmap
 * 
 * @ret The width in pixel.
 */
int tp_bitmap_width(TpBitmap* bitmap);

/** Get the height of the given bitmap.
 *
 * @param bitmap
 * 
 * @ret The height in pixel.
 */
int tp_bitmap_height(TpBitmap* bitmap);

/** Get the color data buffer of the given bitmap.
 *
 * @param bitmap
 *
 * @ret The color buffer.
 */
TpColor* tp_bitmap_bits(TpBitmap* bitmap);

/** Copy the specified region of the give bitmap to the specified postion of dest data buffer.
 *
 * @param bitmap the give bitmap
 * @param rect the specified region of the given bitmap
 * @param data the dest data buffer
 * @param xo the x offset in the dest data buffer
 * @param yo th y offset in the dest data buffer
 * @param dw the horizontal size of the data buffer
 * @param dh the vertical size of the data buffer
 *
 * @ret 0
 */
int tp_bitmap_copy_to_data_bgra32(TpBitmap *bitmap, TpRect *rect, 
								  TpColor *data, int xo, int yo, int dw, int dh);

/** 将给定Buffer中指定区域的颜色数据覆盖到bitmap中指定的位置和区域
 */
int tp_bitmap_copy_from_data_bgr32(TpBitmap *bitmap, TpRect *rect,
                                   TpColor *data, unsigned int xo, unsigned int yo, 
                                   unsigned int dw, unsigned int dh);

TP_DECL_END

#endif /*TP_BITMAP_H*/